﻿@model EquipmentModel

@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.Id)
@Html.HiddenFor(model => model.CategoryMainId)
@Html.HiddenFor(model => model.PId)

<script>
    $(document).ready(function () {
        bindBootstrapTabSelectEvent('equipment-edit');
    });
</script>

<style type="text/css">
    .col-content {
        display: flex;
        align-items: center;
        justify-content: normal;
        height: 34px;
    }
</style>

<div class="content">
    <div class="form-horizontal">
        <div class="row">
            <div class="col-md-12 clearfix">
                <div class="pull-left">
                    @Html.Action("Mode", "Setting", new { modeName = "equipment-advanced-mode" })
                </div>
            </div>
        </div>
        <div id="equipment-edit" class="nav-tabs-custom">
            <ul class="nav nav-tabs">
                @Html.RenderBootstrapTabHeader("tab-info", @T("Admin.Catalog.Categories.Info"), true)
            </ul>
            <div class="tab-content">
                @Html.RenderBootstrapTabContent("tab-info", @TabInfo(), true)
            </div>
        </div>
    </div>
</div>

@{
    //custom tabs
    var eventMessage = new AdminTabStripCreated(this.Html, "equipment-edit");
    EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
    foreach (var eventBlock in eventMessage.BlocksToRender)
    {
        @eventBlock
    }
}

@*save selected tab name*@
<input type="hidden" id="selected-tab-name" name="selected-tab-name" value="@(Html.GetSelectedTabName())">

@helper TabInfo()
{
    <div class="content" style="padding-bottom:0;">
        <div class="form-horizontal">
            <div class="panel-group">
                <div class="panel panel-default">
                    <div class="panel-body">

                        <div class="form-group">
                            <div class="col-md-3">
                                巡检点
                            </div>
                            <div class="col-md-9">
                                <div class="input-group input-group-required">
                                    @if (Model.PId > 0)
                                    {
                                        <text>
                                            @Html.ListBoxFor(model => model.PlaceIds, Model.AvailablePlaces, new { style = "display:none;" })
                                            @Html.EditorFor(model => model.PlaceNames, new { htmlAttributes = new { @class = "form-control", disabled = "disabled" } })
                                        </text>
                                    }
                                    else
                                    {
                                        <text>
                                            @Html.EditorFor(model => model.PlaceIds, new { SelectList = Model.AvailablePlaces })
                                            @Html.ValidationMessageFor(model => model.PlaceIds)
                                            <div class="input-group-btn">
                                                @Html.RequiredHint()
                                            </div>
                                            <script>
                                                $(document).ready(function() {
                                                    var customerRolesIdsInput = $('#@Html.FieldIdFor(model => model.PlaceIds)').data("kendoMultiSelect");
                                                    customerRolesIdsInput.setOptions({
                                                        customerRolesIdsInput: false
                                                    });
                                                    @if (Model.PId>0) {
                                                        <text>
                                                    customerRolesIdsInput.enable(false);
                                                    customerRolesIdsInput.setOptions({
                                                        value: [53],
                                                    });
                                                        </text>
                                                    }
                                                    @if (Model.AvailablePlaces.Count == 0)
                                                    {
                                                        <text>
                                                            customerRolesIdsInput.setOptions({
                                                                enable: false,
                                                                placeholder: '未找到巡检点'
                                                            });
                                                            customerRolesIdsInput._placeholder();
                                                            customerRolesIdsInput._enable();
                                                        </text>
                                                    }
                                                });
                                            </script>
                                        </text>
                                    }
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-3">
                                分类
                            </div>
                            <div class="col-md-9">
                                <div class="input-group input-group-required">
                                    @if (Model.PId > 0)
                                    {
                                        <text>
                                            @Html.HiddenFor(model => model.CategoryId)
                                            @Html.EditorFor(model => model.CategoryName, new { htmlAttributes = new { @class = "form-control", disabled = "disabled" } })
                                        </text>
                                    }
                                    else
                                    {
                                        <text>
                                            @Html.EditorFor(model => model.CategoryId, new { SelectList = Model.AvailableCategories })
                                            @Html.ValidationMessageFor(model => model.CategoryId)
                                            <div class="input-group-btn">
                                                @Html.RequiredHint()
                                            </div>
                                        </text>
                                    }
                                </div>
                            </div>
                        </div>

                        <div class="form-group">
                            <div class="col-md-3">
                                名称
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.Name, required: true)
                                @Html.ValidationMessageFor(model => model.Name)
                            </div>
                        </div>

                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                品牌
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.Manufacturer)
                                @Html.ValidationMessageFor(model => model.Manufacturer)
                            </div>
                        </div>

                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                规格型号
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.Specification)
                                @Html.ValidationMessageFor(model => model.Specification)
                            </div>
                        </div>

                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                单位
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.Unit)
                                @Html.ValidationMessageFor(model => model.Unit)
                            </div>
                        </div>

                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                最低库存
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.StockMin)
                                @Html.ValidationMessageFor(model => model.StockMin)
                            </div>
                        </div>

                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                排序
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(model => model.DisplayOrder)
                                @Html.ValidationMessageFor(model => model.DisplayOrder)
                            </div>
                        </div>

                        <div class="form-group advanced-setting">
                            <div class="col-md-3">
                                发布
                            </div>
                            <div class="col-md-9">
                                @Html.NopEditorFor(x => x.Published)
                                @Html.ValidationMessageFor(model => model.Published)
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
}
